import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;

public class one {
    public static void main(String[] args) {
//        int[] nums = {3, 3, 2, 0, 0, 1};
//        getTwoNotTame(nums);
//        int repeatNumber = findRepeatNumber(nums);
//        System.out.println(repeatNumber);

        int[] nums = {3, 3, 2, 2, 1};

        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
        PriorityQueue<Integer>p=new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return 0;
            }
        });
        p.poll();
        int i = onlyKMTimes(nums, 1, 2);
        System.out.println(i);
    }


    public static int findRepeatNumber(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] == nums[j]) {
                    return nums[i];
                }
            }
        }
        return 0;

    }

    //2个数字出现奇数个，找到这两个数
    public static void getTwoNotTame(int[] nums) {
        int eor = 0;
        for (int i = 0; i < nums.length; i++) {
            eor ^= nums[i];
        }
        int rightOne;
        //找到最右侧1的位置
        rightOne = eor ^ (-eor);
        //eor派
        int onlyOne = 0;
        for (int i = 0; i < nums.length; i++) {
            //找到最右侧不同的1
            if ((rightOne & nums[i]) != 0) {
                onlyOne ^= nums[i];
            }
        }
        System.out.println(onlyOne + "  " + (eor ^ onlyOne));

    }

    public static int onlyKMTimes(int[] arr, int k, int m) {
        int[] ansArry = new int[32];
        for (int num : arr) {
            for (int i = 0; i < 32; i++) {
                //拿出每个位置的1，并且放到ans数组里面
                if (((num >> i & 1)) != 0) {
                    ansArry[i]++;
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < 32; i++) {
            //在i位置上有1
            if (ansArry[i] % m != 0) {
                //找到位置为1的地方，或运算把1放进去
                int i1 = 1 << i;
                ans = ans | i1;
            }
        }
        return ans;
    }

}
